using UnityEngine;
using System.Collections;

public class Character : MonoBehaviour {
	
	public GameObject myGameObject;
	private keys[] PrevKeyPosition;
	const int W = 0, A = 1, S = 2, D = 3;
	enum keys{
		UP, DOWN
	};
	// Use this for initialization
	void Start () {
		int numKeys = 4;
		PrevKeyPosition = new keys[numKeys];
		for (int i = 0; i < numKeys; i++){
			PrevKeyPosition[i] = keys.UP;	
		}
	}
	
	// Update is called once per frame
	void Update () {
		GetInput();
	}
	private void GetInput(){
		if (Input.GetKeyDown(KeyCode.W)){
			Move(W);
		}
		if (Input.GetKeyDown(KeyCode.A)){
			Move(A);
		}
		if (Input.GetKeyDown(KeyCode.S)){
			Move(S);
		}
		if (Input.GetKeyDown(KeyCode.D)){
			Move(D);
		}
	}
	private void Move(int k){
		float x, y, z;
		x = myGameObject.transform.position.x;
		y = myGameObject.transform.position.y;
		z = myGameObject.transform.position.z;
		int increment = 1;
		switch(k)
		{
		case W:
			z += increment;
			break;
		case S:
			z -= increment;
			break;
		case A:
			x -= increment;
			break;
		case D:
			x += increment;
			break;
		default:
			break;
		}
		myGameObject.transform.position = new Vector3(x,y,z);
	}
}
